import React, { Component } from 'react'
import { List, Result, WhiteSpace, Button } from 'antd-mobile'
import Cookies from 'js-cookie'
import { Brief } from 'antd-mobile/lib/list/ListItem'
class Personal extends Component {
  constructor(props) {
    super(props)
    this.state = {}
    this.handleLoginout = this.handleLoginout.bind(this)
  }
  user = JSON.parse(Cookies.get('user'))
  handleLoginout() {
    Cookies.remove('user')
    Cookies.remove('userid')
    this.props.history.replace('/')
  }
  render() {
    return (
      <div>
        <Result
          img={
            <img
              src={`${this.user.header}`}
              alt="header"
              className="result-img"
            />
          }
          title={this.user.username}
          message={this.user.company}
        />
        <List renderHeader={() => '相关信息'}>
          <List.Item multipleLine>
            <Brief>职位：{this.user.post}</Brief>
            <Brief style={{ whiteSpace: 'normal' }}>
              简介：{this.user.info}
            </Brief>
            {this.user.salary ? <Brief>薪资：{this.user.salary}</Brief> : null}
          </List.Item>
          <WhiteSpace />
        </List>
        <Button type="primary" onClick={this.handleLoginout}>
          退出登录
        </Button>
      </div>
    )
  }
}

export default Personal
